﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using Acms.Bll;


public partial class UserControls_HorizontalMenu : System.Web.UI.UserControl
{
    protected override void OnInit(EventArgs e)
    {
        var AcmsPage = this.Page as Acms.AcmsControls.TemplatePage;
        base.OnInit(e);

        menu.DataBound += new EventHandler(menu_DataBound);
        if (!IsPostBack)
        {
            if (AcmsPage != null && AcmsPage.AcmsContext != null)
            {
                dsMainMenu.SiteId = AcmsPage.AcmsContext.SiteId;
                dsMainMenu.CurrentSiteVersion = AcmsPage.AcmsContext.SiteVersion;
            }
        }
    }

    void menu_DataBound(object sender, EventArgs e)
    {
        var AcmsPage = this.Page as Acms.AcmsControls.TemplatePage;
        if (AcmsPage != null && AcmsPage.AcmsContext != null && AcmsPage.AcmsContext.CurrentPost != null)
        {
            //var item = menu.FindItemByUrl(acmsPage.AcmsContext.CurrentPost.Url);
            var item = menu.FindItemByUrl(Page.ResolveUrl(AcmsPage.AcmsContext.CurrentPost.Url));
            if (item != null)
            {
                item.HighlightPath();
            }
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }
}
